/**
 * 团队相关的公共组件
 */
import { getaccessgrouplist,getaccessgrouplistdis  } from '@/api/access_new'
import { log } from 'three'

export default {
    data() {
        return {
            teamList: []
        }
    },
    mounted() {
        this.$nextTick(() => {
            this.getTeamList()
        })
    },
    methods: {
        getTeamList(){
            let sceneId = this.sceneId || this.$route.query.id
            if(!sceneId){
                return;
            }
            let params = {
                // pageIndex: 1,
                // pageSize: 2147483647,
                // testId: testId
                isSuperGroup:false
            };
            getaccessgrouplistdis(params,sceneId).then(({ code, data, message }) => {
                if (code === 1) {
                    let items = data.items || []
                    this.teamList = items
                    this.teamList.forEach((item) => {
                        this.$set(item, 'id', item.teamId); 
                        this.$set(item, 'name', item.teamName); 
                    });
                    console.log(this.teamList,'this.teamListthis.teamList');
                    console.log(this.teamList,'this.teamListthis.teamList');
                } else if (code === -2) {
                    this.teamList = [];
                } else {
                    this.$Message.warning(message);
                }
            }).catch(() => {
                this.$Message.error('获取团队列表异常');
            })
        },
        getTeamNameById(id) {
            let team = this.teamList.find(item => {
                return item.id === id
            })
            return team ? team.name : ''
        }
    }
}